package com.jltx.xq.relaxnewspro.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.jltx.xq.relaxnewspro.R;
import com.jltx.xq.relaxnewspro.adapter.PagerAdapter;


/**
 * Created by bo on 2017/5/18.
 */

public class BaseCollectionFragment extends AbsTopNavigationFragment {
    private PagerAdapter pagerAdapter;


    @Override
    protected PagerAdapter initPagerAdapter() {
        String [] tabTitles ={getContext().getString(R.string.daily),getContext().getString(R.string.reading)
                ,getContext().getString(R.string.news),getContext().getString(R.string.science)};
        pagerAdapter = new PagerAdapter(getChildFragmentManager(),tabTitles) {
            @Override
            public Fragment getItem(int position) {
                Fragment fragment = new CollectionFragment();
                Bundle bundle = new Bundle();
                bundle.putInt(getString(R.string.id_pos),position);
                fragment.setArguments(bundle);
                return fragment;
            }
        };
        return pagerAdapter;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if(getChildFragmentManager().getFragments()!=null){
            getChildFragmentManager().getFragments().clear();
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }
}
